﻿/**************************************************************
 * St. Sana - A file/folder scanner originall designed for    *
 * Open Media Library (open-media-library.googlecode.com)     *
 *                                                            *
 * Available for use by ANY project that wants to use it.     *
 * St. Sana is covered by the Apache 2 license.               *
 * Feel free to use this software however you like so as long *
 * as you follow the guidelines of above mentioned license.   *
 * Written by David J. Shultz (djshultz@gmail.com)            *
 **************************************************************/

using System;
using System.Collections.Generic;

namespace StSana
{
    public class Video
    {
        public IList<int> EpisodeNumbers;
        /// <summary>
        /// Private IList of filenames in the Video object
        /// </summary>
        IList<string> filenames;

        public bool ContainsMoreThenOneEpisode
        {
            get { return EpisodeNumbers.Count > 1; }
        }

        private string name;
        private bool nonStandardVideo;

        /// <summary>
        /// Getter/Setter if the Video object is Non Standard
        /// </summary>
        public bool IsNonStandardVideo
        {
            get; set;
        }

        /// <summary>
        /// Getter/Setter for the Video objects name.
        /// </summary>
        public string Name
        {
            get; set;
        }

        /// <summary>
        /// Empty Constructor
        /// </summary>
        public Video()
        {
            EpisodeNumbers = new List<int>();
            filenames = new List<string>();
        }

        /// <summary>
        /// Numer of Files in the Video Object.
        /// </summary>
        public int FileCount
        {
            get { return filenames.Count; }
        }

        /// <summary>
        /// An IList of the filenames in the Video object.
        /// </summary>
        public IList<string> Files
        {
            get { return filenames; }
        }

        /// <summary>
        /// Adds a filename to the Video object
        /// </summary>
        /// <param name="filename">The full path to a file</param>
        public void AddFile(string filename)
        {
            filenames.Add(filename);
        }

        /// <summary>
        /// Removes a file from the Video object if it exists.
        /// </summary>
        /// <param name="filename">The full path to a file</param>
        /// <returns>The full path to the file removed, null if no file was removed.</returns>
        public string RemoveFile(string filename)
        {
            if (filenames.Contains(filename))
            {
                filenames.Remove(filename);
                return filename;
            }

            return null;
        }

        /// <summary>
        /// Get the filename at the given index
        /// </summary>
        /// <param name="index"></param>
        /// <returns>The full path to the filename requested for the given index, null if the index was invalid.</returns>
        public string GetFileNameAtIndex(int index)
        {
            if (index <= filenames.Count - 1)
                return filenames[index];

            return null;
        }
    }
}
